#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/ioctl.h>
#include <errno.h>
#include <string.h>
#include <fcntl.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <sys/select.h>



/* autres includes (eventuellement) */

#define ERROR_EXIT(str) {perror(str);exit(EXIT_FAILURE);}

#define PORT "33000"
#define NUM_MACHINES 5
#define LISTENQ 1024
#define MAXBUF 1024

/* definition du type des infos */
/* de connexion des processus dsm */
struct dsm_proc_conn  {
	int rank;
	/* a completer */
};
typedef struct dsm_proc_conn dsm_proc_conn_t; 

/* definition du type des infos */
/* d'identification des processus dsm */
struct dsm_proc {   
	pid_t pid;
	dsm_proc_conn_t connect_info;
};

typedef struct{
	int fd_com;
	char* buffer3;
} clt_t;

typedef struct dsm_proc dsm_proc_t;

int creer_socket(int type, int *port_num);
void create_socket_connect(char* token, int* fd);

int supprime_retour(char* line);

ssize_t Sendline(int sockd, const void *vptr, size_t n);
ssize_t Readline(int sockd, void *vptr, size_t maxlen);
